package day05;

import org.junit.Test;

import java.io.File;
import java.lang.annotation.ElementType;
import java.sql.Date;

public class file {

    @Test
    public void test2(){
        File file1 = new File("hello.txt");
        File file2 = new File("d:\\io\\hi.txt");

        System.out.println(file1.getAbsolutePath());
        System.out.println(file1.getPath());
        System.out.println(file1.getName());
        System.out.println(file1.getParent());
        System.out.println(file1.length());
        System.out.println(new Date(file1.lastModified()));

        System.out.println();

        System.out.println(file2.getAbsolutePath());
        System.out.println(file2.getPath());
        System.out.println(file2.getName());
        System.out.println(file2.getParent());
        System.out.println(file2.length());
        System.out.println(file2.lastModified());


    }

    @Test
    public void test3(){
        File file = new File("D:\\BaiduNetdiskDownload\\课件笔记源码资料\\新建文件夹");

        String[] list = file.list();
        for(String s : list){
            System.out.println(s);
        }

        System.out.println();

        File[] files = file.listFiles();
        for(File f : files){
            System.out.println(f);
        }


    }

    @Test
    public void test4() {
        File file1 = new File("hello.txt");
        File file2 = new File("d:\\io\\hi.txt");

        boolean b = file1.renameTo(file2);
        System.out.println(b);


    }
    @Test
    public void test5() {

        File file1 = new File("d:\\io\\hi.txt");
        System.out.println(file1.isDirectory());
        System.out.println(file1.isFile());
        System.out.println(file1.exists());
        System.out.println(file1.canRead());
        System.out.println(file1.canWrite());
        System.out.println(file1.isHidden());

    }
    @Test
    public void test6() throws ClassNotFoundException {
        Class clazz1 = Person1.class;
        System.out.println(clazz1);

        Person1 p1 = new Person1();
        Class clazz2 = p1.getClass();
        System.out.println(clazz2);

        Class clazz3 = Class.forName("day05.Person1");
        System.out.println(clazz3);

        ClassLoader classLoader = file.class.getClassLoader();
        Class clazz4 = classLoader.loadClass("day05.Person1");
        System.out.println(clazz4);

    }
    @Test
    public void test7() {
        Class c1 = Object.class;
        Class c2 = Comparable.class;
        Class c3 = String[].class;
        Class c4 = int[][].class;
        Class c5 = ElementType.class;
        Class c6 = Override.class;
        Class c7 = int.class;
        Class c8 = void.class;
        Class c9 = Class.class;


        int[] a = new int[10];
        int[] b = new int[100];
        Class c10 = a.getClass();
        Class c11 = b.getClass();


        System.out.println(c11 == c10);



    }


}
